<template>
        <view class="goods-carts">
            <view class="goods-carts-fixed">
             <uni-goods-nav :fill="true" :options="options" :buttonGroup="buttonGroup" @click="onClick" @buttonClick="buttonClick" />
            </view>
        </view>
</template>

<script>

const app = getApp();
import uniGoodsNav from '@/components/uni-goods-nav/uni-goods-nav';
import { GoodsCarList} from '@/api/http';

export default {
    props: [],
    components: {uniGoodsNav},
    data () {
        return {
            options: [
                {
                    icon: 'headphones',
                    text: '客服'
                },
                // {
                //     icon: 'shop',
                //     text: '店铺',
                //     info: 2,
                //     infoBackgroundColor: '#007aff',
                //     infoColor: 'red'
                // },
                {
                    icon: 'cart',
                    text: '购物车',
                    info: 0
                }
            ],
            buttonGroup: [
                {
                    text: '加入购物车',
                    backgroundColor: 'linear-gradient(90deg, #fbc535, #f99630)',
                    color: '#fff'
                },
                {
                    text: '立即购买',
                    backgroundColor: 'linear-gradient(90deg,#f97626, #fb5420)',
                    color: '#fff'
                }
            ],
        }
    },
    mounted () {

        this.iniCar()
    },
    methods: {
        
        
        iniCar(){

            let userId = app.globalData.userId

            if (userId) {

                GoodsCarList({	"pageNum": 1,"pageSize": 1,userId}).then( res =>{

                    if(res.code == 200){

                        this.options[1].info = res.total
                    }

                })

            }
            
        },

        onClick(e) {

            console.log('9999999',e)

            let idx = e.index

            if(idx == 0){

                uni.showToast({
                    title: `去咨询`,
                    icon: 'none'
                });

            }
            else if(idx == 1){

               this.$goNext('/pages/carpage/index','switchTab')

            }

           
        },
        buttonClick(e) {
            // this.styleClick(e.index == 1 ? 'buy' : 'car');

            this.$emit('buttonClick', e.index == 1 ? 'buy' : 'car' )
        },

    }
}
</script>

<style scoped lang="scss">
.goods-carts {
    height: 50px;
    padding-bottom: var(--status-bar-height);
    box-sizing: content-box;
  
}
.goods-carts-fixed{
     /* #ifndef APP-NVUE */
    display: flex;
    /* #endif */
    flex-direction: column;
    position: fixed;
    left: 0;
    right: 0;
    /* #ifdef H5 */
    left: var(--window-left);
    right: var(--window-right);
    /* #endif */
    padding-bottom: var(--status-bar-height);
    bottom: 0;
    background: #fff;
}
</style>
